-
Notifications
You must be signed in to change notification settings - Fork 936
Adds zoom fit selected and zoom fit all functionalities. #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Integrate upstream
…o upstream_zoom_fit
Llcoolsouder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous version of contextMenuEvent allows subclasses to completely customize what shows in the context menu. This change would make it so every subclass gets the zoom actions menu (but only if connected to a DataFlowGraphModel).
It might be more in the spirit to the original to keep the new zoom actions as public methods, but leave them disconnected, allowing end users to connect them where they see fit. (We could have a whole collection of inherited default impl actions that could be useful in this way.)
src/GraphicsView.cpp
Outdated
| bool isZoomFitMenu; | ||
|
|
||
| auto const scenePos = mapToScene(event->pos()); | ||
| if (auto *dfModel = dynamic_cast<DataFlowGraphModel *>(&nodeScene()->graphModel())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would caution against coupling the GraphicsView to anything more specific than AbstractGraphModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice! To solve this, a virtual method was defined in AbstractGraphModel and overridden in DataFlowGraphModel, keeping GraphicsView bound to AbstractGraphModel only.
|
|
||
| void GraphicsView::zoomFitAll() | ||
| { | ||
| fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's supposed to do the same thing as GraphicsView::centerScene. Do we need both?
I've noticed odd behavior in GraphicsView::centerScene. Is zoomFitAll better? (i.e. should this replace the old impl?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The central difference between GraphicsView::centerScene and GraphicsView::zoomFitAll is that the former only centralizes the scene without altering the zoom. Since the GraphicsView::centerScene is used to centralize newly loaded scenes I believe both are needed.
src/GraphicsView.cpp
Outdated
| QMenu *menu = nullptr; | ||
|
|
||
| if (!nodeScene()) return; | ||
| bool isZoomFitMenu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is uninitialized unless all of the immediately following conditions are met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable is now initialized as false.
src/GraphicsView.cpp
Outdated
|
|
||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Type of change
Description
The zoom fit selected and zoom fit all features allow for the user to change focus between one, some or all exiting nodes, fitting them in the view accordingly. The video below demonstrates both functionalities:
Zoom_fit_test.mp4
Testing